home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / src-server / w_evnthndlr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  21.5 KB  |  534 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         w_evnthndlr.c
  5. * RCS:          $Header: w_evnthndlr.c,v 1.6 91/03/14 03:13:36 mayer Exp $
  6. * Description:  Interfaces to Xtoolkit Event Handler Routines
  7. * Author:       Niels Mayer, HPLabs
  8. * Created:      Thu Nov 23 06:11:39 1989
  9. * Modified:     Thu Oct  3 20:40:45 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. **
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: w_evnthndlr.c,v 1.6 91/03/14 03:13:36 mayer Exp $";
  42.  
  43. #include <stdio.h>
  44. #include <Xm/Xm.h>        /* Xm/Xm.h only needed for "winterp.h"*/
  45. #include "winterp.h"
  46. #include "user_prefs.h"
  47. #include "xlisp/xlisp.h"
  48.  
  49. static LVAL k_RAW, k_NONMASKABLE,
  50.   s_EVHANDLER_WIDGET, s_EVHANDLER_XEVENT, s_EVHANDLER_BUTTON, s_EVHANDLER_TIME,
  51.   s_EVHANDLER;
  52.  
  53. #define RAW_OPTION         (1L<<0)
  54. #define NONMASKABLE_OPTION (1L<<1)
  55.  
  56. extern Widget Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(); /* w_classes.c */
  57.  
  58.  
  59. /******************************************************************************
  60.  * This is an XtEventHandler procedure that is called by the various add-
  61.  * event-handler methods in this file. It serves to call the lisp evaluator
  62.  * on the lexical closure that was created by the add-event-handler-methods.
  63.  * It will bind the symbols EVHANDLER_WIDGET EVHANDLER_XEVENT to
  64.  * the widget and xevent that caused the event handler to fire.
  65. ******************************************************************************/
  66. static void Winterp_Event_Handler_Proc(widget_id, client_data, event)
  67.      Widget    widget_id;
  68.      XtPointer client_data;
  69.      XEvent*   event;
  70. {
  71.   extern LVAL xlenv, xlfenv;
  72.   LVAL        oldenv, oldfenv, l_evalforms, s_name;
  73.   CONTEXT     cntxt;
  74.   LVAL        bindings_list, s_bindname;
  75.   LVAL        c_evhandler = get_evhandler_closure((LVAL) client_data);
  76.  
  77.   /*
  78.    * Most of this procedure looks alot like xleval.c:evfun(), which is what
  79.    * the evaluator calls when a functional form is to be evaluated. The
  80.    * main difference is that instead of calling xlabind() to bind the
  81.    * formal parameter symbols of a function to their values in the new
  82.    * lexical environment frame returned by xlframe(getenv(fun)), we 
  83.    * bind symbols on bindings_list...
  84.    */
  85.   
  86.   /* protect some pointers */
  87.   xlstkcheck(3);
  88.   xlsave(oldenv);
  89.   xlsave(oldfenv);
  90.   xlsave(l_evalforms);
  91.   
  92.   /* create a new environment frame */
  93.   oldenv = xlenv;
  94.   oldfenv = xlfenv;
  95.   xlenv = xlframe(getenvt(c_evhandler)); /* note: changed getenv()-->getenvt() due to name conflict with stdlib.h:getenv() */
  96.   xlfenv = getfenv(c_evhandler);
  97.  
  98.   /* bind  local variables specified durng call to :SET/:ADD_EVENT_HANDLER */
  99.   for (bindings_list = getargs(c_evhandler);
  100.        consp(bindings_list); bindings_list = cdr(bindings_list)) {
  101.     s_bindname = car(bindings_list);
  102.     if (s_bindname == s_EVHANDLER_WIDGET) {
  103.       xlpbind(s_bindname, get_evhandler_widget((LVAL) client_data), xlenv);
  104.     }
  105.     else if (s_bindname == s_EVHANDLER_BUTTON) {
  106.       xlpbind(s_bindname, (event) ? cvfixnum((FIXTYPE) ((XButtonEvent*) event)->button) : NIL, xlenv);
  107.     }
  108.     else if (s_bindname == s_EVHANDLER_TIME) {
  109.       xlpbind(s_bindname, (event) ? cvfixnum((FIXTYPE) ((XButtonEvent*) event)->time) : NIL, xlenv);
  110.     }
  111.     else if (s_bindname == s_EVHANDLER_XEVENT) {
  112.       xlpbind(s_bindname, (event) ? cv_xevent(event) : NIL, xlenv);
  113.     }
  114.     else {
  115.       extern char temptext[]; /* from winterp.c */
  116.       sprintf(temptext,
  117.           "Unknown binding name in Event Handler. Valid symbols are [%s %s %s %s].",
  118.           (char*) getstring(getpname(s_EVHANDLER_WIDGET)),
  119.           (char*) getstring(getpname(s_EVHANDLER_BUTTON)),
  120.           (char*) getstring(getpname(s_EVHANDLER_TIME)),
  121.           (char*) getstring(getpname(s_EVHANDLER_XEVENT)));
  122.       xlerror(temptext, s_bindname);
  123.     }
  124.   }
  125.  
  126.   /* setup the implicit block */
  127.   if (s_name = getname(c_evhandler))
  128.     xlbegin(&cntxt, CF_RETURN, s_name);
  129.   
  130.   /* execute the block */
  131.   if (s_name && setjmp(cntxt.c_jmpbuf))
  132.     { }
  133.   else
  134.     for (l_evalforms = getbody(c_evhandler); consp(l_evalforms); 
  135.      l_evalforms = cdr(l_evalforms))
  136.       xleval(car(l_evalforms));
  137.   
  138.   /* finish the block context */
  139.   if (s_name)
  140.     xlend(&cntxt);
  141.   
  142.   /* restore the environment */
  143.   xlenv = oldenv;
  144.   xlfenv = oldfenv;
  145.   
  146.   /* restore the stack */
  147.   xlpopn(3);
  148. }
  149.  
  150.  
  151. /******************************************************************************
  152.  * (send <widget> :ADD_EVENT_HANDLER [:RAW] [:NONMASKABLE] <event_mask>
  153.  *                                   <event_data_bindings_list> <code>)
  154.  * (send <widget> :SET_EVENT_HANDLER [:RAW] [:NONMASKABLE] <event_mask>
  155.  *                                   <event_data_bindings_list> <code>)
  156.  * ==> returns an <EVHANDLEROBJ> which identifies the handler.
  157.  *
  158.  * Optional keyword :RAW indicates that XtAddRawEventHandler() will
  159.  * be invoked so as to not affect the widget's input mask nor for
  160.  * it to select for events. Otherwise XtAddEventHandler() will get 
  161.  * called.
  162.  *
  163.  * Optional keyword :NONMASKABLE indicates that the handler should
  164.  * be called for nonmaskable events.
  165.  * 
  166.  * <event_mask> is a FIXNUM which is the value of the an event mask.
  167.  * event masks may be combined by doing a bitwise or via the xlisp
  168.  * 'logior' function. The following event mask constants have been
  169.  * defined: NO_EVENT_MASK, KEY_PRESS_MASK, KEY_RELEASE_MASK,
  170.  * BUTTON_PRESS_MASK, BUTTON_RELEASE_MASK, ENTER_WINDOW_MASK,
  171.  * LEAVE_WINDOW_MASK, POINTER_MOTION_MASK, POINTER_MOTIONHINT_MASK,
  172.  * BUTTON1_MOTION_MASK, BUTTON2_MOTION_MASK, BUTTON3_MOTION_MASK,
  173.  * BUTTON4_MOTION_MASK, BUTTON5_MOTION_MASK, BUTTON_MOTION_MASK,
  174.  * KEYMAP_STATE_MASK, EXPOSURE_MASK,  VISIBILITY_CHANGE_MASK
  175.  * STRUCTURE_NOTIFY_MASK, RESIZE_REDIRECT_MASK, SUBSTRUCTURE_NOTIFY_MASK
  176.  * SUBSTRUCTURE_REDIRECT_MASK, FOCUS_CHANGE_MASK, PROPERTY_CHANGE_MASK
  177.  * COLORMAP_CHANGE_MASK, OWNER_GRAB_BUTTON_MASK.
  178.  *
  179.  * <event_data_bindings_list> is a list of symbols that get
  180.  * bound to data specific to the action that caused the event
  181.  * handler to fire. These symbols get lexically bound during
  182.  * the execution of the event-handler <code>.
  183.  * Valid symbols are:
  184.  * EVHANDLER_WIDGET -- bound to the widgetobj of the event
  185.  * EVHANDLER_XEVENT -- bound to the XEvent that fired handler.
  186.  * EVHANDLER_BUTTON -- fixnum -- the button or keycode
  187.  * EVHANDLER_TIME   -- fixnum -- the timestamp.
  188.  *
  189.  * <code> is a list of lisp-forms to be evaluated when the eventhandler
  190.  * fires.
  191.  *
  192.  * The eventhandler may be removed by giving the <EVHANDLEROBJ> to
  193.  * procedure REMOVE_EVENT_HANDLER.
  194.  *
  195.  * Note that the :SET_EVENT_HANDLER variant does exactly the same
  196.  * thing as :ADD_EVENT_HANDLER except that it ensure that only one
  197.  * event handler with the given <event_mask>, :RAW and :NONMASKABLE
  198.  * specifications exist on <widget>. It will remove all other matching
  199.  * event handlers in order to set the current event handler. THis
  200.  * function is useful for making interactive changes to an event
  201.  * handler without having to remember to remove the previous
  202.  * handler. Note that :SET_EVENT_HANDLER is slower, so it should 
  203.  * not be used in cases where speed is important.
  204.  *
  205.  * NOTE: the EVHANDLER_TIME and EVHANDLER_BUTTON
  206.  * binding values may return gibberish if the eventhandler returned
  207.  * a event->type that doesn't define those fields. THis is
  208.  * currently just a kludge for motif functions that require
  209.  * the event->button info (popup menus) or event->time info
  210.  * (XmClipboard*). Hopefully I'll come up with something better.
  211.  *
  212.  * void XtAddEventHandler(widget, eventMask, other, proc, closure)
  213.  *     Widget           widget;
  214.  *     EventMask       eventMask;
  215.  *     Boolean         other;
  216.  *     XtEventHandler  proc;
  217.  *     XtPointer       closure;
  218.  * 
  219.  * void XtAddRawEventHandler(widget, eventMask, other, proc, closure)
  220.  *     Widget           widget;
  221.  *     EventMask       eventMask;
  222.  *     Boolean         other;
  223.  *     XtEventHandler  proc;
  224.  *     XtPointer       closure;
  225.  ******************************************************************************/
  226. LVAL Widget_Class_Meta_Method_Add_Event_Handler();
  227. LVAL Widget_Class_Method_ADD_EVENT_HANDLER()
  228. {
  229.   return (Widget_Class_Meta_Method_Add_Event_Handler(FALSE));
  230. }
  231. LVAL Widget_Class_Method_SET_EVENT_HANDLER()
  232. {
  233.   return (Widget_Class_Meta_Method_Add_Event_Handler(TRUE));
  234. }
  235.  
  236. LVAL Widget_Class_Meta_Method_Add_Event_Handler(one_evhandler_per_mask_p)
  237.      Boolean one_evhandler_per_mask_p;
  238. {
  239.   extern LVAL s_lambda, xlenv, xlfenv;
  240.   Boolean raw_p, nonmaskable_p;
  241.   EventMask event_mask;
  242.   Widget widget_id;
  243.   LVAL o_self, l_fargs, l_code, evhandler_obj;
  244.  
  245.   /* get <widget_instance> */
  246.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&o_self);
  247.  
  248.   /* get optional :RAW or :NONMASKABLE keyword args */
  249.   raw_p = nonmaskable_p = FALSE;
  250.   if (moreargs() && ((*xlargv == k_RAW))) {
  251.     nextarg();
  252.     raw_p = TRUE;
  253.   }
  254.   if (moreargs() && ((*xlargv == k_NONMASKABLE))) {
  255.     nextarg();
  256.     nonmaskable_p = TRUE;
  257.   }
  258.   
  259.   /* get required <event_mask> arg, a fixnum */
  260.   event_mask = (EventMask) getfixnum(xlgafixnum());
  261.  
  262.   /* get <event_data_bindings_list> -- args to be bound at call time.
  263.      NOTE: may want to check that these args are valid... No biggie
  264.      though invalid names will get get caught at runtime,
  265.      when the eventhandler fires. */
  266.   l_fargs = xlgalist();        
  267.   
  268.   /* get <code> */
  269.   l_code = xlgalist();
  270.   xllastarg();
  271.  
  272.   /* 
  273.    * if this procedure is being called from the :set_event_handler method 
  274.    * (indicated by one_evhandler_per_mask_p == TRUE), 
  275.    * then remove all eventhandlers on <widget> matching <event_mask>
  276.    * <raw_p> and <nonmaskable_p>.
  277.    */
  278.   if (one_evhandler_per_mask_p) {
  279.     extern LVAL v_savedobjs;    
  280.     int  i = Wso_Hash(o_self);
  281.     LVAL l_hbucket = getelement(v_savedobjs, i); /* a list of objects, including all evhandler-objs on this widget */
  282.     LVAL obj;
  283.     LVAL l_prev = NIL;
  284.     while (l_hbucket) {        /* while there are elements in the hashbucket */
  285.       obj = car(l_hbucket);    /* obj points to cur elt */
  286.       if (evhandlerobj_p(obj)
  287.       && (get_evhandler_mask(obj) == event_mask)
  288.       && (((get_evhandler_options(obj) & RAW_OPTION) ? TRUE : FALSE) == raw_p)
  289.       && (((get_evhandler_options(obj) & NONMASKABLE_OPTION) ? TRUE : FALSE) == nonmaskable_p)
  290.       && (get_evhandler_widget(obj) == o_self)) {
  291.  
  292.     if (get_evhandler_options(obj) & RAW_OPTION)
  293.       XtRemoveRawEventHandler(widget_id, event_mask,
  294.                   ((get_evhandler_options(obj) & NONMASKABLE_OPTION) ? TRUE : FALSE),
  295.                   Winterp_Event_Handler_Proc, (XtPointer) obj);
  296.     else
  297.       XtRemoveEventHandler(widget_id, event_mask,
  298.                    ((get_evhandler_options(obj) & NONMASKABLE_OPTION) ? TRUE : FALSE),
  299.                    Winterp_Event_Handler_Proc, (XtPointer) obj);
  300.  
  301.     l_hbucket = cdr(l_hbucket); /* l_hbucket now points to next elt or NIL */
  302.     if (!l_prev)
  303.       setelement(v_savedobjs, i, l_hbucket); /* remove first, head is now next elt */
  304.     else
  305.       rplacd(l_prev, l_hbucket); /* remove cur, point previous to next */
  306.       }
  307.       else {
  308.     l_prev = l_hbucket;
  309.     l_hbucket = cdr(l_hbucket);
  310.       }
  311.     }
  312.   }
  313.  
  314.   /* 
  315.    * create the client_data to be sent to (*XtEventHandler)()
  316.    * That procedure takes the client_data and extracts the widget-object,
  317.    * and the closure, and uses these to execute the event handler's code.
  318.    */
  319.   xlsave1(evhandler_obj);    /* protect some pointers */
  320.   evhandler_obj = new_evhandlerobj();
  321.   set_evhandler_widget(evhandler_obj, o_self);
  322.   set_evhandler_mask(evhandler_obj, event_mask);
  323.   {
  324.     long options = 0L;
  325.     if (raw_p)
  326.       options |= RAW_OPTION;    /* this bit tells REMOVE_EVENT_HANDLER which removeproc to call */
  327.     if (nonmaskable_p)
  328.       options |= NONMASKABLE_OPTION; /* we need this bit for REMOVE_EVENT_HANDLER */
  329.     set_evhandler_options(evhandler_obj, options);
  330.   }
  331.   set_evhandler_closure(evhandler_obj, 
  332.             xlclose(s_EVHANDLER, s_lambda, l_fargs, l_code, xlenv, xlfenv));
  333.   
  334.   if (raw_p)
  335.     XtAddRawEventHandler(widget_id, event_mask, nonmaskable_p, 
  336.              Winterp_Event_Handler_Proc, (XtPointer) evhandler_obj);
  337.   else
  338.     XtAddEventHandler(widget_id, event_mask, nonmaskable_p, 
  339.               Winterp_Event_Handler_Proc, (XtPointer) evhandler_obj);
  340.  
  341.   /*
  342.    * Enter the evhandler_obj in v_savedobjs, so that it gets marked.
  343.    * This way, it won't be garbage collected while the eventhandler is
  344.    * active. REMOVE_EVENT_HANDLER, and :destroy on the widget will
  345.    * end up removing the evhandlerobj from v_savedobjs,  which will
  346.    * permit it to be garbage collected.
  347.    */
  348.   { 
  349.     int  i = Wso_Hash(o_self);
  350.     LVAL l_hbucket;
  351.     extern LVAL v_savedobjs;
  352.     
  353.     xlsave1(l_hbucket);
  354.     l_hbucket = cons(evhandler_obj, getelement(v_savedobjs, i));
  355.     setelement(v_savedobjs, i, l_hbucket);
  356.     xlpop(/*l_hbucket*/);
  357.   }
  358.  
  359.   xlpop(/*evhandler_obj*/);
  360.   return (evhandler_obj);
  361. }
  362.  
  363. /******************************************************************************
  364.  * (REMOVE_EVENT_HANDLER <EVHANDEROBJ>)
  365.  * returns true.
  366.  *
  367.  * This procedure removes the eventhander corresponding to the 
  368.  * <EVHANDLEROBJ> returned by method :ADD_EVENT_HANDLER
  369.  *
  370.  * void XtRemoveEventHandler(widget, eventMask, other, proc, closure)
  371.  *     Widget          widget;
  372.  *     EventMask      eventMask;
  373.  *     Boolean          other;
  374.  *     XtEventHandler proc;
  375.  *     XtPointer      closure;
  376.  *
  377.  * void XtRemoveRawEventHandler(widget, eventMask, other, proc, closure)
  378.  *     Widget            widget;
  379.  *     EventMask        eventMask;
  380.  *     Boolean            other;
  381.  *     XtEventHandler   proc;
  382.  *     XtPointer    closure;
  383.  ******************************************************************************/
  384. LVAL Weh_Prim_REMOVE_EVENT_HANDLER()
  385. {
  386.   LVAL evhandler_obj;
  387.   LVAL o_widget;
  388.   Widget widget_id;
  389.   Boolean raw_p, nonmaskable_p;
  390.   extern LVAL true;
  391.  
  392.   evhandler_obj = xlga_evhandlerobj();
  393.   xllastarg();
  394.  
  395.   /* check if this evhandler hasn't already been removed */
  396.   if ((o_widget = get_evhandler_widget(evhandler_obj)) == NIL)
  397.     xlerror("EventHandler associated with <evhandlerobj> has already been removed.", evhandler_obj);
  398.   
  399.   /* mark the evhandler_obj as being removed */
  400.   set_evhandler_widget(evhandler_obj, NIL);
  401.   
  402.   {
  403.     long options;
  404.     options = get_evhandler_options(evhandler_obj);
  405.     raw_p = (options & RAW_OPTION) ? TRUE : FALSE;
  406.     nonmaskable_p = (options & NONMASKABLE_OPTION) ? TRUE : FALSE;
  407.   }
  408.  
  409.   if (!(widget_id = get_widgetobj_widgetID(o_widget)))
  410.     xlerror("widget object not properly initialized by :isnew.", o_widget);
  411.   
  412.   if (raw_p)
  413.     XtRemoveRawEventHandler(widget_id, get_evhandler_mask(evhandler_obj),
  414.                 nonmaskable_p, Winterp_Event_Handler_Proc,
  415.                 (XtPointer) evhandler_obj);
  416.   else
  417.     XtRemoveEventHandler(widget_id, get_evhandler_mask(evhandler_obj),
  418.              nonmaskable_p, Winterp_Event_Handler_Proc,
  419.              (XtPointer) evhandler_obj);
  420.                 
  421.   /* remove <evhandler_obj> from v_savedobjs allowing it to be garbage collected */
  422.   {
  423.     extern LVAL v_savedobjs;
  424.     int i = Wso_Hash(o_widget); /* note that we hash all evhandlers on the same widget to the same hashbucket */
  425.     LVAL l_hbucket = getelement(v_savedobjs, i);
  426.     LVAL l_prev = NIL;
  427.  
  428.     while (l_hbucket && (car(l_hbucket) != evhandler_obj)) {
  429.       l_prev = l_hbucket;
  430.       l_hbucket = cdr(l_hbucket);
  431.     }
  432.     if (!l_hbucket)
  433.       xlerror("Internal error in REMOVE_EVENT_HANDLER -- couldn't remove <evhandlerobj> from v_savedobjs. Hash error?",
  434.           evhandler_obj);
  435.     if (!l_prev)        /* first elt matched */
  436.       setelement(v_savedobjs, i, cdr(l_hbucket));
  437.     else
  438.       rplacd(l_prev, cdr(l_hbucket));
  439.   }
  440.   
  441.   return (true);
  442. }
  443.  
  444.  
  445. /******************************************************************************
  446.  * (send <widget> :BUILD_EVENT_MASK)
  447.  * ==> this returns as a FIXNUM the event mask representing the logical OR of
  448.  * all event masks for event handlers registered on <widget>. This includes
  449.  * masks set by XtAddEventHandler(), all event translations & accelerators.
  450.  * 
  451.  * EventMask XtBuildEventMask(widget)
  452.  *     Widget widget;
  453.  ******************************************************************************/
  454. LVAL Widget_Class_Method_BUILD_EVENT_MASK()
  455. {
  456.   LVAL self;
  457.   Widget widget_id;
  458.  
  459.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  460.   xllastarg();
  461.   
  462.   return (cvfixnum((FIXTYPE) XtBuildEventMask(widget_id)));
  463. }
  464.  
  465.  
  466. /******************************************************************************
  467.  *
  468.  ******************************************************************************/
  469. LVAL Weh_Init()
  470. {
  471.   LVAL s_NO_EVENT_MASK = xlenter("NO_EVENT_MASK");
  472.   LVAL s_KEY_PRESS_MASK = xlenter("KEY_PRESS_MASK");
  473.   LVAL s_KEY_RELEASE_MASK = xlenter("KEY_RELEASE_MASK");
  474.   LVAL s_BUTTON_PRESS_MASK = xlenter("BUTTON_PRESS_MASK");
  475.   LVAL s_BUTTON_RELEASE_MASK = xlenter("BUTTON_RELEASE_MASK");
  476.   LVAL s_ENTER_WINDOW_MASK = xlenter("ENTER_WINDOW_MASK");
  477.   LVAL s_LEAVE_WINDOW_MASK = xlenter("LEAVE_WINDOW_MASK");
  478.   LVAL s_POINTER_MOTION_MASK = xlenter("POINTER_MOTION_MASK");
  479.   LVAL s_POINTER_MOTIONHINT_MASK = xlenter("POINTER_MOTIONHINT_MASK");
  480.   LVAL s_BUTTON1_MOTION_MASK = xlenter("BUTTON1_MOTION_MASK");
  481.   LVAL s_BUTTON2_MOTION_MASK = xlenter("BUTTON2_MOTION_MASK");
  482.   LVAL s_BUTTON3_MOTION_MASK = xlenter("BUTTON3_MOTION_MASK");
  483.   LVAL s_BUTTON4_MOTION_MASK = xlenter("BUTTON4_MOTION_MASK");
  484.   LVAL s_BUTTON5_MOTION_MASK = xlenter("BUTTON5_MOTION_MASK");
  485.   LVAL s_BUTTON_MOTION_MASK = xlenter("BUTTON_MOTION_MASK");
  486.   LVAL s_KEYMAP_STATE_MASK = xlenter("KEYMAP_STATE_MASK");
  487.   LVAL s_EXPOSURE_MASK = xlenter("EXPOSURE_MASK");
  488.   LVAL s_VISIBILITY_CHANGE_MASK = xlenter("VISIBILITY_CHANGE_MASK");
  489.   LVAL s_STRUCTURE_NOTIFY_MASK = xlenter("STRUCTURE_NOTIFY_MASK");
  490.   LVAL s_RESIZE_REDIRECT_MASK = xlenter("RESIZE_REDIRECT_MASK");
  491.   LVAL s_SUBSTRUCTURE_NOTIFY_MASK = xlenter("SUBSTRUCTURE_NOTIFY_MASK");
  492.   LVAL s_SUBSTRUCTURE_REDIRECT_MASK = xlenter("SUBSTRUCTURE_REDIRECT_MASK");
  493.   LVAL s_FOCUS_CHANGE_MASK = xlenter("FOCUS_CHANGE_MASK");
  494.   LVAL s_PROPERTY_CHANGE_MASK = xlenter("PROPERTY_CHANGE_MASK");
  495.   LVAL s_COLORMAP_CHANGE_MASK = xlenter("COLORMAP_CHANGE_MASK");
  496.   LVAL s_OWNER_GRAB_BUTTON_MASK = xlenter("OWNER_GRAB_BUTTON_MASK");
  497.  
  498.   setvalue(s_NO_EVENT_MASK, cvfixnum((FIXTYPE) NoEventMask));
  499.   setvalue(s_KEY_PRESS_MASK, cvfixnum((FIXTYPE) KeyPressMask));
  500.   setvalue(s_KEY_RELEASE_MASK, cvfixnum((FIXTYPE) KeyReleaseMask));
  501.   setvalue(s_BUTTON_PRESS_MASK, cvfixnum((FIXTYPE) ButtonPressMask));
  502.   setvalue(s_BUTTON_RELEASE_MASK, cvfixnum((FIXTYPE) ButtonReleaseMask));
  503.   setvalue(s_ENTER_WINDOW_MASK, cvfixnum((FIXTYPE) EnterWindowMask));
  504.   setvalue(s_LEAVE_WINDOW_MASK, cvfixnum((FIXTYPE) LeaveWindowMask));
  505.   setvalue(s_POINTER_MOTION_MASK, cvfixnum((FIXTYPE) PointerMotionMask));
  506.   setvalue(s_POINTER_MOTIONHINT_MASK, cvfixnum((FIXTYPE) PointerMotionHintMask));
  507.   setvalue(s_BUTTON1_MOTION_MASK, cvfixnum((FIXTYPE) Button1MotionMask));
  508.   setvalue(s_BUTTON2_MOTION_MASK, cvfixnum((FIXTYPE) Button2MotionMask));
  509.   setvalue(s_BUTTON3_MOTION_MASK, cvfixnum((FIXTYPE) Button3MotionMask));
  510.   setvalue(s_BUTTON4_MOTION_MASK, cvfixnum((FIXTYPE) Button4MotionMask));
  511.   setvalue(s_BUTTON5_MOTION_MASK, cvfixnum((FIXTYPE) Button5MotionMask));
  512.   setvalue(s_BUTTON_MOTION_MASK, cvfixnum((FIXTYPE) ButtonMotionMask));
  513.   setvalue(s_KEYMAP_STATE_MASK, cvfixnum((FIXTYPE) KeymapStateMask));
  514.   setvalue(s_EXPOSURE_MASK, cvfixnum((FIXTYPE) ExposureMask));
  515.   setvalue(s_VISIBILITY_CHANGE_MASK, cvfixnum((FIXTYPE) VisibilityChangeMask));
  516.   setvalue(s_STRUCTURE_NOTIFY_MASK, cvfixnum((FIXTYPE) StructureNotifyMask));
  517.   setvalue(s_RESIZE_REDIRECT_MASK, cvfixnum((FIXTYPE) ResizeRedirectMask));
  518.   setvalue(s_SUBSTRUCTURE_NOTIFY_MASK, cvfixnum((FIXTYPE) SubstructureNotifyMask));
  519.   setvalue(s_SUBSTRUCTURE_REDIRECT_MASK, cvfixnum((FIXTYPE) SubstructureRedirectMask));
  520.   setvalue(s_FOCUS_CHANGE_MASK, cvfixnum((FIXTYPE) FocusChangeMask));
  521.   setvalue(s_PROPERTY_CHANGE_MASK, cvfixnum((FIXTYPE) PropertyChangeMask));
  522.   setvalue(s_COLORMAP_CHANGE_MASK, cvfixnum((FIXTYPE) ColormapChangeMask));
  523.   setvalue(s_OWNER_GRAB_BUTTON_MASK, cvfixnum((FIXTYPE) OwnerGrabButtonMask));
  524.  
  525.   k_RAW = xlenter(":RAW");
  526.   k_NONMASKABLE = xlenter(":NONMASKABLE");
  527.   s_EVHANDLER_WIDGET = xlenter("EVHANDLER_WIDGET");
  528.   s_EVHANDLER_XEVENT = xlenter("EVHANDLER_XEVENT");
  529.   s_EVHANDLER_BUTTON = xlenter("EVHANDLER_BUTTON");
  530.   s_EVHANDLER_TIME   = xlenter("EVHANDLER_TIME");
  531.   s_EVHANDLER = xlenter("EVHANDLER");
  532. }  
  533.